package com.demo2do.fms.scheduler.entity.appointment;

import java.util.Date;

import javax.persistence.Column;

import com.demo2do.fms.entity.report.AppointmentStatus;

/**
 * 驳运车累计行驶公里数报表预约记录
 *
 * @author Ark
 *
 */
public class VehicleMileageAppointment {

    private Long id;
    
    /** 预约号 */
    private String code;
    
    /** 开始导出时间 */
    private Date handleTime;
    
    /** 完成导出时间 */
    private Date finishTime;
    
    /** 报表状态 */
    private String status;
    
    /** 报表文件url */
    private String url;
    
    /** 驳回理由 */
    private String reason;
    
    /** ==============  预约条件 =============== */
    
    /** 预约公司 */
    private Long organizationId;
    
    /** 调度指令开始日期 */
    private String beginShipmentDate;
    
    /** 调度指令结束日期 */
    private String endShipmentDate;
    
    /** 报销开始日期 */
    private String beginReimburseDate;
    
    /** 报销结束日期 */
    private String endReimburseDate;
    
    /** ==============  预约条件 =============== */
    
    /** 创建人 */
    private Long creator;

    /** 创建时间 */
    private Date createTime;

    /** 最后修改人 */
    private Long lastOperator;
    
    /** 最后修改时间 */
    private Date lastModifyTime;

    @Column(name = "is_disabled")
    private Boolean disabled;
    
    /**
     * The default constructor
     */
    public VehicleMileageAppointment() {
    }
    
    /**
     * @param operator
     * @return
     */
    public VehicleMileageAppointment adopt(Long operator) {
        this.status = AppointmentStatus.PENDING.name();
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @param reason
     * @param operator
     * @return
     */
    public VehicleMileageAppointment reject(String reason, Long operator) {
        this.status = AppointmentStatus.REJECTED.name();
        this.reason = reason;
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * start handle appointment
     * 
     * @param operator
     * @return
     */
    public VehicleMileageAppointment start(Long operator) {
        this.handleTime = new Date();
        this.status = AppointmentStatus.PROCESSING.name();
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * handle appointment success
     * 
     * @param url
     * @param operator
     * @return
     */
    public VehicleMileageAppointment success(String url, Long operator) {
        this.url = url;
        this.finishTime = new Date();
        this.status = AppointmentStatus.COMPLETED.name();
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * handle appointment failed
     * 
     * @param operator
     * @return
     */
    public VehicleMileageAppointment fail(Long operator) {
        this.status = AppointmentStatus.FAILED.name();
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @param operator
     * @return
     */
    public VehicleMileageAppointment expire(Long operator) {
        this.status = AppointmentStatus.EXPIRED.name();
        this.url = null;
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the handleTime
     */
    public Date getHandleTime() {
        return handleTime;
    }

    /**
     * @return the finishTime
     */
    public Date getFinishTime() {
        return finishTime;
    }

    /**
     * @return
     */
    public String getStatus() {
        return status;
    }

    /**
     * @return the url
     */
    public String getUrl() {
        return url;
    }
    
    /**
     * @return
     */
    public String getReason() {
        return reason;
    }

    /**
     * @return the organizationId
     */
    public Long getOrganizationId() {
        return organizationId;
    }

    /**
     * @return the beginShipmentDate
     */
    public String getBeginShipmentDate() {
        return beginShipmentDate;
    }

    /**
     * @return the endShipmentDate
     */
    public String getEndShipmentDate() {
        return endShipmentDate;
    }

    /**
     * @return the beginReimburseDate
     */
    public String getBeginReimburseDate() {
        return beginReimburseDate;
    }

    /**
     * @return the endReimburseDate
     */
    public String getEndReimburseDate() {
        return endReimburseDate;
    }

    /**
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param handleTime the handleTime to set
     */
    public void setHandleTime(Date handleTime) {
        this.handleTime = handleTime;
    }

    /**
     * @param finishTime the finishTime to set
     */
    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }

    /**
     * @param status
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = url;
    }
    
    /**
     * @param reason
     */
    public void setReason(String reason) {
        this.reason = reason;
    }

    /**
     * @param organizationId the organizationId to set
     */
    public void setOrganizationId(Long organizationId) {
        this.organizationId = organizationId;
    }

    /**
     * @param beginShipmentDate the beginShipmentDate to set
     */
    public void setBeginShipmentDate(String beginShipmentDate) {
        this.beginShipmentDate = beginShipmentDate;
    }

    /**
     * @param endShipmentDate the endShipmentDate to set
     */
    public void setEndShipmentDate(String endShipmentDate) {
        this.endShipmentDate = endShipmentDate;
    }

    /**
     * @param beginReimburseDate the beginReimburseDate to set
     */
    public void setBeginReimburseDate(String beginReimburseDate) {
        this.beginReimburseDate = beginReimburseDate;
    }

    /**
     * @param endReimburseDate the endReimburseDate to set
     */
    public void setEndReimburseDate(String endReimburseDate) {
        this.endReimburseDate = endReimburseDate;
    }

    /**
     * @param creator the creator to set
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }
    
}
